//
//  webViewController.m
//  IntroductionApp
//
//  Created by John Doe on 11/11/02.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "webViewController.h"

@implementation webViewController

@synthesize myWebView = _myWebView;
@synthesize backBtn = _backBtn;
@synthesize advanceBtn = _advanceBtn;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.myWebView.delegate = self;
    
    NSURL *url = [NSURL URLWithString:@"http://ameblo.jp/koike-tatsuya"];
    NSURLRequest *req = [NSURLRequest requestWithURL:url];
    [self.myWebView loadRequest:req];
    
    // Btn非活性
    self.backBtn.enabled = NO;
    self.advanceBtn.enabled = NO;
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    _myWebView = nil;
    _backBtn = nil;
    _advanceBtn = nil;
}

-(void)dealloc{
    [ super dealloc ];
    
    [ _myWebView release ];
    [ _backBtn release ];
    [ _advanceBtn release ];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

/* ====================================================================================== */
#pragma mark - web Delegate
/* ====================================================================================== */

-(void)webViewDidFinishLoad:(UIWebView*)webView{
     
    if(webView.canGoForward){
        self.backBtn.enabled = NO;
        self.advanceBtn.enabled = YES;
    }
    
    if(webView.canGoBack){
        self.backBtn.enabled = YES;
        self.advanceBtn.enabled = NO;
    }
}


@end
